package com.example.arithmeticleetcode.leetcode;

/**
 * @program: arithmetic-leetcode
 * @description: 1470. 重新排列数组
 * @author: FangZhen
 * @create: 2020-06-05 10:14
 **/
public class Demo25 {

    public static void main(String[] args) {
        int[] nums1 = {2, 5, 1, 3, 4, 7};
        shuffle(nums1, 3);
        int[] nums2 = {1, 2, 3, 4, 4, 3, 2, 1};
        shuffle(nums2, 4);
        int[] nums3 = {1, 1, 2, 2};
        shuffle(nums3, 2);
    }

    public static int[] shuffle(int[] nums, int n) {
        int[] arr = new int[nums.length];
        int j = 0;
        for (int i = 0, len = nums.length; i < len; i++) {
            arr[i] = nums[j];
            arr[i + 1] = nums[n + j];
            j++;
            i++;
        }
        return arr;
    }
}
